﻿using Leo.Awesome.Attachment;
using Leo.Awesome.DictionaryManagement;
using Leo.Awesome.Infrastructure.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;

namespace Leo.Awesome.Infrastructure;

[DependsOn(typeof(AttachmentDomainSharedModule),
    typeof(DictionaryManagementDomainSharedModule))]
public class InfrastructureDomainSharedModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        InfrastructureGlobalFeatureConfigurator.Configure();
        InfrastructureModuleExtensionConfigurator.Configure();
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<InfrastructureDomainSharedModule>();
        });

        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Add<InfrastructureResource>("en")
                .AddBaseTypes(typeof(AbpValidationResource))
                .AddVirtualJson("/Localization/Infrastructure");

            options.DefaultResourceType = typeof(InfrastructureResource);
        });

        Configure<AbpExceptionLocalizationOptions>(options =>
        {
            options.MapCodeNamespace("Infrastructure", typeof(InfrastructureResource));
        });
    }
}
